package pers.goetboy.sys.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import pers.goetboy.common.AbstractController;
import pers.goetboy.common.EntityState;
import pers.goetboy.common.exception.service.ServiceTipsException;
import pers.goetboy.sys.model.entity.Menu;
import pers.goetboy.sys.model.entity.Role;
import pers.goetboy.sys.services.RoleService;

import java.util.List;

/**
 * @author goetb
 */
@RestController("/role")
public class RoleController extends AbstractController<Role,RoleService> {

    /**
     * 获取角色列表
     */
    @GetMapping("/list")
    public IPage<Role> list(Integer current, Integer size) {
        return service.page(new Page(current, size));
    }

    /**
     * 更新角色菜单信息
     *
     * @param id    角色id
     * @param menus 菜单列表
     */
    @PutMapping(value = "/updateMenu/{id}")
    public void updateRoleMenu(@PathVariable Long id, @RequestBody List<Menu> menus) throws ServiceTipsException {
        service.updateRoleMenu(id, menus);
    }

}
